{extend name="/fool" /}
{block name="css"}
<link rel="stylesheet" href="/css/admin/product_list.css">
<style>
    .layui-form-onswitch{
        /*background: #1989FA;*/
        /*border-color: #1989FA;*/
    }
    .layui-upload-img{
        height:200px;
        width:200px;
        margin: 10px;
    }
    .value{
        text-align: left;
    }
    .dt{
        width:200px;
        height:200px;
    }
    #xssj{
    	margin:10px 0;
    	padding:10px;
    	border:1px solid #000;
    }
</style>
{/block}
{block name="menu_content"}
<form class="layui-form" action="" method="post" enctype="multipart/form-data">
    <ul id="content">
        <li class="li">
            <table class="one">
                <tr>
                    <td class="one-one">机台名称：</td>
                    <td class="value">
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="{$list.name}" autocomplete="off" class="layui-input" placeholder="机台名称" disabled>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">租赁人：</td>
                    <td class="value">
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="{$list.user.name}" autocomplete="off" class="layui-input" placeholder="租赁人名称" disabled>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">所属服务中心：</td>
                    <td class="value">
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="{$list.fwgl.name}" autocomplete="off" class="layui-input" placeholder="服务中心名称" disabled>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">设备管理人：</td>
                    <td class="value">
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="{$list.userpid.name}" autocomplete="off" class="layui-input" placeholder="设备管理人名称" disabled>
                        </div>
                        搜索设备管理人账号：
	                    <div class="layui-input-inline">
	                        <input type="text" name="batterybaid" autocomplete="off" id="jtnumtp" class="layui-input" placeholder="设备管理人账号">
	                    </div>
	                    <button type="button" class="layui-btn sstp">搜索</button>
	                    <div class="layui-input-inline" id="sstp">
	                        <input type="text" name="batterybaid" autocomplete="off" class="layui-input" disabled style="background:#e7e7e7;">
	                    </div>
	                    <button type="button" class="layui-btn" id="fptp">
	                    	{if $list.userpid.name}
	                    	重新绑定该机台
	                    	{else}
	                    	绑定该机台
	                    	{/if}
	                    </button>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">商家：</td>
                    <td class="value">
                        <div>
                        	<div class="layui-input-inline">
	                            <input type="text" name="name" value="{$list.business.name}" autocomplete="off" class="layui-input" placeholder="商家名称" disabled>
	                        </div>
		                    搜索商家账号：
		                    <div class="layui-input-inline">
		                        <input type="text" name="batterybaid" autocomplete="off" id="jtnum" class="layui-input" placeholder="商家账号">
		                    </div>
		                    <button type="button" class="layui-btn ss">搜索</button>
		                    <div class="layui-input-inline" id="ss">
		                        <input type="text" name="batterybaid" autocomplete="off" class="layui-input" disabled style="background:#e7e7e7;">
		                    </div>
		                    <button type="button" class="layui-btn" id="fp">
		                    	{if $list.business.name}
		                    	重新绑定该机台
		                    	{else}
		                    	绑定该机台
		                    	{/if}
		                    </button>
		                </div>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">是否运行：</td>
                    <td class="value">
                        <div style="margin-left:0;" class="layui-input-block">
                        	{if $list.status == 1}
                            <input type="radio" name="status" value="1" title="是" checked>
                            <input type="radio" name="status" value="2" title="否">
                            {else}
                            <input type="radio" name="status" value="1" title="是">
                            <input type="radio" name="status" value="2" title="否" checked>
                            {/if}
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="one-one">
                        <button type="button" class="listbu layui-btn">取消</button>
                    </td>
                    <td class="value">
                        <button type="submit" class="fh layui-btn">保存</button>
                    </td>
                </tr>
            </table>
        </li>
    </ul>
</form>
<script>
	"{if isset($error)}"
	alert("{$error}");
	"{/if}"
	$("#fptp").click(function(){
        var val = $("#sstp").find('input').val();
        var sid = $("#sstp").find('input').attr('sid');
        if(val.length>0){
            $.post("{:url('upfptp')}",{'id':"{$list.id}",'sid':sid,},function(res){
            	console.log(res);
                history.go(0);
            },'json')
        }
    })
    $(".sstp").click(function(){
        var num = $("#jtnumtp").val();
        if(num.length>1){
            $.post("{:url('upsstp')}",{username:num},function(res){
                	console.log(res);
                if(res.code == 200){
	                $("#sstp").find('input').val(res.list.name);
	                $("#sstp").find('input').attr('sid',res.list.id);
                }else if(res.code == 500){
                	alert('该用户不是租赁商');
                }else{
                	console.log(res);
                }
            },'json')
        }else{
            $("#ss").find('input').val('');
        }
    })
	$("#fp").click(function(){
        var val = $("#ss").find('input').val();
        var sid = $("#ss").find('input').attr('sid');
        if(val.length>0){
            $.post("{:url('upfp')}",{'id':"{$list.id}",'sid':sid,},function(res){
            	console.log(res);
                history.go(0);
            },'json')
        }
    })
    $(".ss").click(function(){
        var num = $("#jtnum").val();
        if(num.length>1){
            $.post("{:url('upss')}",{username:num},function(res){
                	console.log(res);
                if(res.code == 200){
	                $("#ss").find('input').val(res.list.name);
	                $("#ss").find('input').attr('sid',res.list.id);
                }else if(res.code == 500){
                	alert('该用户不是租赁商');
                }else{
                	console.log(res);
                }
            },'json')
        }else{
            $("#ss").find('input').val('');
        }
    })
	$(".addbus").click(function(){
		$.post("{:url('busadd')}",{},function(res){
			console.log(res);
		},'json')
	})
    $(".dtqx").click(function(){
        var id = $(this).attr('sid');
        $(this).closest(".imgdtdiv").hide();
        $.post("{:url('atlas/delete')}",{id},function(date){console.log(date)},'json');
    })

    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    $(".listbu").click(function(){
        history.back(-1);
    })
</script>
{/block}